package cn.swanit.iot;

import cn.swanit.iot.verticles.HttpServerVerticle;
import cn.swanit.iot.verticles.TcpServerVerticle;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import io.vertx.core.impl.cpu.CpuCoreSensor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class App {

    public static void main(String[] args) {
        Vertx vertx = Vertx.vertx(new VertxOptions()
                .setEventLoopPoolSize(CpuCoreSensor.availableProcessors())
                .setWorkerPoolSize(CpuCoreSensor.availableProcessors() * 10));

        int tcpPort = 5555;
        vertx.deployVerticle(new TcpServerVerticle(tcpPort), event -> {
            if (event.succeeded()) {
                log.info("TCP服务启动成功 {}", tcpPort);
            } else {
                log.info("TCP服务启动失败, {}", event.cause().getMessage());
            }
        });

        int httpPort = 8090;
        vertx.deployVerticle(new HttpServerVerticle(httpPort), event -> {
            if (event.succeeded()) {
                log.info("HTTP服务启动成功 {}", httpPort);
            } else {
                log.info("HTTP服务启动失败, {}", event.cause().getMessage());
            }
        });
    }
}
